#include "job.h"

Job::Job() :delete_after_use(true),
			timeout(0)
			{
			add_ref();
			}
Job::~Job(){}

int
Job::release(){
	int ref;
	AtomicAdd(_ref, -1);
	if ((ref =AtomicGet(_ref)) == 0){
		NOTICE_LOG("Job (%s) reference is 0, going to delete it", name.c_str());
		delete this;
	}
	return ref;
}

void
Job::add_ref(){
	AtomicAdd(_ref, 1);
}

int
Job::get_ref(){
	return AtomicGet(_ref);
}

void
Job::work(){
	TRACE_LOG("Do Job (%s)", name.c_str());
}
